package com.konke.smartpad_huahao.UI.view;

import android.Manifest;
import android.content.Intent;
import android.net.Uri;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.konke.smartpad_huahao.R;
import com.konke.smartpad_huahao.UI.MainContract;
import com.konke.smartpad_huahao.UI.presenter.MainPresenter;
import com.tbruyelle.rxpermissions2.RxPermissions;
import com.zsj.comminlibrary.base.BaseActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import io.alterac.blurkit.BlurLayout;

public class MainActivity extends BaseActivity<MainPresenter> implements MainContract.IMainView {

    @BindView(R.id.bl)
    BlurLayout mBl;
    @BindView(R.id.img_code)
    ImageView mImgCode;
    @BindView(R.id.rel_code)
    RelativeLayout mRelCode;

    @Override
    protected void initView() {
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);
        mBlurLayouts.add(mBl);
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void onResume() {
        super.onResume();
        new RxPermissions(this).request(Manifest.permission.RECORD_AUDIO,
                Manifest.permission.ACCESS_NETWORK_STATE,
                Manifest.permission.INTERNET,
                Manifest.permission.READ_PHONE_STATE,
                Manifest.permission.WAKE_LOCK,
                Manifest.permission.DISABLE_KEYGUARD,
                Manifest.permission.CHANGE_WIFI_STATE,
                Manifest.permission.ACCESS_WIFI_STATE,
                Manifest.permission.ACCESS_FINE_LOCATION,
                Manifest.permission.WRITE_EXTERNAL_STORAGE)
                .subscribe(aBoolean -> {
                    if (aBoolean) {
                        mPresenter.getDeviceStatus();
                    } else {
                        showToast("为保证App正常运行,请赋予App读写内存权限");
                        Intent localIntent = new Intent();
                        localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        localIntent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
                        localIntent.setData(Uri.fromParts("package", getPackageName(), null));
                        startActivity(localIntent);
                    }
                });
    }

    @Override
    protected void onStart() {
        super.onStart();
    }

    @Override
    protected void onStop() {
        super.onStop();
    }



}
